package com.mtsmda.jpa.run;


import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.Persistence;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;

import com.mtsmda.jpa.domain.perClassTable.Programmer;

public class CriteriaAPIDemoRun {
	
	public static void main(String[] args) {
		EntityManager entityManager = Persistence.createEntityManagerFactory(
				"MTSMDA").createEntityManager();
		CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
		CriteriaQuery<Programmer> createQuery = criteriaBuilder.createQuery(Programmer.class);
		Root<Programmer> from = createQuery.from(Programmer.class);
		
		TypedQuery<Programmer> createQuery2 = entityManager.createQuery(createQuery);
		List<Programmer> resultList = createQuery2.getResultList();
		for(Programmer p : resultList){
			System.out.print(p.getIdProgrammer() + "\t");
			System.out.print(p.getKnowCSS() + "\t");
			System.out.print(p.getKnowHTML());
			System.out.println();
		}
		
		
		
		entityManager.close();
	}
	
}